package com.STS.ELearning.DAO
{
	/**
	* @author www.comtaste.com
	*/
	
	import com.STS.ELearning.VO.SinavlarVO;
	
	import flash.data.SQLConnection;
	import flash.data.SQLStatement;
	import flash.errors.SQLError;
	import flash.events.SQLErrorEvent;
	import flash.events.SQLEvent;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	
	
	public class Sinavlar extends BaseDao
	{
	
		
		private static var instance:Sinavlar;
		private static const TABLE_NAME:String="Sinavlar";
		public static function getInstance():Sinavlar {
			if( instance == null )
				instance = new Sinavlar( new SingletonLock );
			return instance;
		}
		
	
		public function Sinavlar( lock: SingletonLock) {
			super(TABLE_NAME);
		}
		
		
		public function updateRow( rowItem:SinavlarVO):Boolean {
			var text:String = 'UPDATE main.'+TABLE_NAME+' SET ad = @ad,sinavyol=@sinavyol, otarih = @otarih, dtarih = @dtarih, idkategori = @idkategori, idkonu = @idkonu, zorluk = @zorluk, sira = @sira, maxUygulamaSayisi = @maxUygulamaSayisi WHERE id=@id;';
			var parameters:Array= [ {name:"id", value:rowItem.id}, {name:"ad", value:rowItem.ad}, {name:"sinavyol", value:rowItem.sinavyol}, {name:"otarih", value:rowItem.otarih}, {name:"dtarih", value:rowItem.dtarih}, {name:"idkategori", value:rowItem.idkategori}, {name:"idkonu", value:rowItem.idkonu}, {name:"zorluk", value:rowItem.zorluk}, {name:"sira", value:rowItem.sira}, {name:"maxUygulamaSayisi", value:rowItem.maxUygulamaSayisi} ];
			return super.executeSingleResult(text,parameters);
		}
		
		public function insertRow( rowItem:SinavlarVO ):Boolean {
			var text:String = 'INSERT INTO main.'+TABLE_NAME+'( id, ad, sinavyol, otarih, dtarih, idkategori, idkonu, zorluk, sira, maxUygulamaSayisi ) VALUES ( ('+getId()+'),@ad,@sinavyol,@otarih,@dtarih,@idkategori,@idkonu,@zorluk,@sira,@maxUygulamaSayisi );';
			var params:Array = [  {name:"ad", value:rowItem.ad}, {name:"sinavyol", value:rowItem.sinavyol},{name:"otarih", value:rowItem.otarih}, {name:"dtarih", value:rowItem.dtarih}, {name:"idkategori", value:rowItem.idkategori}, {name:"idkonu", value:rowItem.idkonu}, {name:"zorluk", value:rowItem.zorluk}, {name:"sira", value:rowItem.sira}, {name:"maxUygulamaSayisi", value:rowItem.maxUygulamaSayisi} ];
			
			return super.executeSingleResult(text,params,rowItem,"id");
			
		}
		
		public function deleteRow( rowItem:SinavlarVO ):Boolean {
			var text:String = 'DELETE FROM main.'+TABLE_NAME+' WHERE main.'+TABLE_NAME+'.id = @id;';
			var params:Array = [ {name:"id", value:rowItem.id} ];
			return super.executeSingleResult(text,params);
		}
	}
}

class SingletonLock {}
